package com.itcast.impl;

import com.itcast.dao.AccountDao;
import com.itcast.pojo.Account;
import com.itcast.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service("accountService")
@Transactional(rollbackFor = Exception.class)
public class AccountServiceImpl implements AccountService {

    @Autowired
    AccountDao accountDao;

    @Override
    public List<Account> findAll() {
        System.out.println("业务层:查询所有账户....");
        List<Account> accounts=accountDao.findAll();
        for (int i = 0; i < accounts.size(); i++) {
            System.out.println(accounts.get(i));
        }
        return accounts;
    }

    @Override
    public void saveAccount(Account account) {
        accountDao.saveAccount(account);
        accountDao.saveAccount(account);
    }
}
